package com.bw.zg3park2212.adpter

import android.widget.TextView
import com.bw.base.entity.SiginEntity
import com.bw.base.entity.SiginEntityItem
import com.bw.zg3park2212.R
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class SiginListAdpter:BaseMultiItemQuickAdapter<SiginEntityItem,BaseViewHolder>() {
    init {
        addItemType(0,R.layout.item_siginlist)
        addItemType(1,R.layout.item_siginlist2)
    }
    override fun convert(helper: BaseViewHolder, item: SiginEntityItem) {
        helper.setText(R.id.sigin_location,item.location)
        val stuate = helper.getView<TextView>(R.id.sigin_stuate)
        if (item.status=="正常"){
            stuate.setTextColor(context.getColor(R.color.color_kongxian))
            stuate.setBackgroundResource(R.drawable.bg_kongxian)
            stuate.setText("正常")
        }else if (item.status=="迟到"){
            stuate.setTextColor(context.getColor(R.color.color_weihu))
            stuate.setBackgroundResource(R.drawable.bg_weihu)
            stuate.setText("迟到")
        }else if (item.status=="早退"){
            stuate.setTextColor(context.getColor(R.color.color_zhanyong))
            stuate.setBackgroundResource(R.drawable.bg_zganyong)
            stuate.setText("早退")
        }

        if (item.type==0){
            val split = item.morningCheckIn.split(" ")
            helper.setText(R.id.sigin_time,split[0])
            helper.setText(R.id.sigin_aftertime,"上班:"+split[1])
        }else{
            val split = item.afternoonCheckIn.split(" ")
            helper.setText(R.id.sigin_time,split[0])
            helper.setText(R.id.sigin_aftertime2,"下班:"+split[1])
        }
    }

}